<template>
    <el-main>
      <h1>添加</h1>
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="名称">
          <el-input v-model="form.title" disabled></el-input>
        </el-form-item>
        <el-form-item label="秒杀价格">
          <el-input v-model="form.seckillPrice"></el-input>
        </el-form-item>
        <el-form-item label="秒杀开始时间">
          <el-date-picker
            v-model="form.seckillCreatedate"
            type="datetime"
            placeholder="选择日期时间">
          </el-date-picker>
          <!--<el-input v-model="form.seckillCreatedate"></el-input>-->
        </el-form-item>
        <el-form-item label="秒杀结束时间">
          <el-date-picker
            v-model="form.seckillEnddate"
            type="datetime"
            placeholder="选择日期时间">
          </el-date-picker>
          <!--<el-input v-model="form.seckillEnddate"></el-input>-->
        </el-form-item>
        <el-form-item label="秒杀数量">
          <el-input v-model="form.seckillStock"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">添加</el-button>
        </el-form-item>
      </el-form>
    </el-main>
</template>

<script>
  import { addMiao } from "@/api/miaosha/miaosha";
    export default {
        name: "miaoadd",
      data() {
        return {
          formData:{},
          form:{}
        }
      },created() {
          this.search();
      },
      methods:{
        onSubmit() {
            addMiao(this.form).then(res=>{
              if (res) {
                this.$message("添加成功");
                this.$router.push("index")
              }
            })
        },
        search() {
          if (this.$route.query.formDate != null) {
            this.formData=this.$route.query.formDate;
            this.form={
              skuId:this.formData.id,
              title:this.formData.title,
            }
            console.log(this.formData);
          }
        }
      }
    }
</script>

<style scoped>

</style>
